﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using UniversityStudentManagemnetSystem.BLL;
using UniversityStudentManagemnetSystem.DAO.DAL;

namespace UniversityStudentManagemnetSystem.UI
{
    public partial class PersonalEmployeeInformationaspx : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                
            }

        }

        protected void searchButton_Click(object sender, EventArgs e)
        {
            try
            {
                string searchText = searchItemTextBox.Text;
                EmployeeManager manager = new EmployeeManager();
                Employee anEmployee = manager.GetEmployeeFor(searchText);
                nameTextBox.Text = anEmployee.Name;
                fatherNameTextBox.Text = anEmployee.FatherName;
                motherNameTextBox.Text = anEmployee.MotherName;
                nationalIdTextBox.Text = anEmployee.NationalIdNumber;
                emaiTextBox.Text = anEmployee.Email;
                contactNoTextBox.Text = anEmployee.ContactNumber;
                designationTextBox.Text = anEmployee.Designation.DesignationName;
                dateOfBirthTextBox.Text = anEmployee.DateOfBirth.ToString();
                joiningDateTextBox.Text = anEmployee.JoiningDate.ToString();
                presentAddressTextBox.Text = anEmployee.PresentAaddres;
                permanentAddressTextBox.Text = anEmployee.PermanentAaddres;
            }
                catch(FormatException exception)
                {
                    messageLabel.ForeColor = Color.Red;
                    messageLabel.Text = exception.Message;
                }
            catch (Exception exception)
            {

                messageLabel.ForeColor = Color.Red;
                messageLabel.Text = exception.Message;
            }
            


        }
    }
}